package com.soyoung.util;

import java.util.*;
import java.util.concurrent.locks.ReentrantLock;
import java.util.function.Function;
import java.util.stream.Collectors;

/**
 * @Author : zhq
 * @since : 2018/5/10
 */
public class StrUtils implements Runnable{
    public static ReentrantLock lock = new ReentrantLock();
    public static int i = 0;

    @Override
    public void run() {
        for (int j = 0; j < 100; j++){
            lock.lock();
            try
            {
                i++;
            }
            finally
            {
                lock.unlock();
            }
        }
    }

    public static void main(String[] args) throws InterruptedException{
       /* String a = "abcdeabccc";
        String [] b = a.split("");
        List<String> a1 = Arrays.asList(b);
        Map<String,Long> result =a1.stream().filter(link->!"a".equals(link)).collect(
                Collectors.groupingBy(Function.identity(), Collectors.counting())
        );
        result.forEach((k,v)->{
            System.out.println(k+"出现的次数为:"+v+"次");
        });

        Integer [] ins ={1,3,4,5,2};
        int temp=0;
        for (int i=0;i<ins.length;i++){
            for (int j=0;j<ins.length-i-1;j++){
                if (ins[j+1]<ins[j]){
                    temp = ins[j+1];
                    ins[j+1] = ins[j];
                    ins[j] = temp;
                }
            }

        }
        System.out.println(ins);*/

        StrUtils test = new StrUtils();
        Thread t1 = new Thread(test);
        Thread t2 = new Thread(test);
        t1.start();
        t2.start();
        t1.join();
        t2.join();
        System.out.println(i);


    }
}
